﻿using System.Text;
using System.Xml.Linq;
using BattleFury.Lib.Extensions;

namespace BattleFury.Lib.Controls
{
	public class UpDown
		: Selector
	{
		public int Value { get; set; }
		public int Minimum { get; set; }
		public int Maximum { get; set; }

		public override void Deserialize(XElement element, object callingObject)
		{
			base.Deserialize(element, callingObject);

			Value = element.GetInt("Value", 0);
			Minimum = element.GetInt("Minimum", 0);
			Maximum = element.GetInt("Maximum", 0);

			var sb = new StringBuilder();
			for (var i = Minimum; i <= Maximum; i++)
			{
				sb.Append(string.Format("{0},", i));
			}
			ItemsSource = sb.ToString().Substring(0, sb.ToString().Length - 1);
		}
	}
}